package com.example.activemq.mq;

import com.example.activemq.producer.Producer;
import com.example.activemq.producer.Publisher;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;

@RunWith(SpringRunner.class)
@ContextConfiguration(classes = ActivemqConfig.class)
@SpringBootTest
public class ActivemqTestDemo {

    @Resource
    private Producer producer;

    @Resource
    private Publisher publisher;

    @Test
    public void testMQ(){
        for (int i = 0; i < 10; i++) {
            producer.sendMessage("test", "消息实体" + i);
        }
    }

    @Test
    public void testPub(){
        for (int i = 0; i < 10; i++){
            publisher.publish("test.topic", "Topic message" + i);
        }
    }


}
